package com.stoneframe.util.baseString;

public class StringHelper {
	
	//字符串比较
	public static void StringCompareEmp(){
		String str="Hello World";
		String anotherString="hello world";
		Object objStr=str;
		
		System.out.println(str.compareTo(anotherString));
		System.out.println(str.compareToIgnoreCase(anotherString));
		System.out.println(str.compareTo(objStr.toString()));
	}
	
	// 删除字符串中的一个字符
	public static String removeCharAt(String str,int pos){
		return str.substring(0, pos)+str.substring(pos+1);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("字符串比较:");
		StringCompareEmp();
		System.out.print("查找字符串最后一次出现的位置:");
		System.out.println("Hello world ,Hello Runoob".lastIndexOf("Runoob"));
		System.out.println("删除字符串中的一个字符:"+removeCharAt("this is Java", 3));
		System.out.println("字符串替换:"+"Hello World".replace("o", "2"));
		System.out.println("字符串替换:"+"Hello World".replaceFirst("o", "2"));
		System.out.println("字符串替换:"+"Hello World".replaceAll("o", "2"));
		System.out.println("字符串反转:"+new StringBuilder("runoob").reverse().toString());
		System.out.println("字符串搜索:"+"Google Runoob Taobao".indexOf("Runoob"));
	}

}
